package com.lcx.plugin.tool;

import com.intellij.notification.Notification;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.project.Project;

/**
 * @author daxiong
 * @date 2023/6/16 下午4:09
 */
public class ComponentUtil {

    /**
     * balloon: 鼠标点击一下通知窗口，通知就会消失(可能要多点击几下，消失的也比较慢)。
     * sitskyBalloon:鼠标点击通知窗口不会消失，必须点击×才行。
     */
    private static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("EasyDB.NotificationGroup", NotificationDisplayType.BALLOON, true);


    public static void showNotification(Project project, String message, boolean success) {
        NotificationType notificationType;
        if (success) {
            notificationType = NotificationType.INFORMATION;
        } else {
            notificationType = NotificationType.ERROR;
        }
        // 使用通知组创建通知
        Notification notification = NOTIFICATION_GROUP.createNotification(message, notificationType);
        // 将通知放入通知总线
        Notifications.Bus.notify(notification, project);
    }
}
